package com.keyinong.jishibao.adapter;

import java.util.ArrayList;

import com.keyinong.jishibao.R;
import com.keyinong.jishibao.R.color;
import com.keyinong.jishibao.R.drawable;
import com.keyinong.jishibao.bean.AddressBean;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class DiaLogAddressAdapter extends BaseAdapter {
	Context context;
	ArrayList<String> list;
	int isSelect=-1;

	public DiaLogAddressAdapter(Context context, ArrayList<String> list) {
		super();
		this.context = context;
		this.list = list;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}
	public void select(int isSelect)
	{
		this.isSelect=isSelect;
	}
	
	@Override
	public View getView(int position, View view, ViewGroup parent) {
		final ViewHandler handler;
		if (view == null) {
			handler = new ViewHandler();
			view = LayoutInflater.from(context).inflate(
					R.layout.item_listview_dialogaddress, null);
			handler.tv_dailogAddress = (TextView) view
					.findViewById(R.id.tv_dailogAddress);
			view.setTag(handler);
		}else {
			handler=(ViewHandler) view.getTag();
		}
		handler.tv_dailogAddress.setText(list.get(position));
	
		if(isSelect==position)
		{
			handler.tv_dailogAddress.setSelected(true);
			handler.tv_dailogAddress.setPressed(true);
			
//			handler.tv_dailogAddress.setBackgroundColor(color.dailog_);
		}else {
			handler.tv_dailogAddress.setSelected(false);
			handler.tv_dailogAddress.setPressed(false);
		}
		

		return view;
	}

	class ViewHandler {
		TextView tv_dailogAddress;
	}
	

}
